 
//function to add multiple highlights
var intTextBox=0;
var addHighlight = function(){
	
	intTextBox = intTextBox + 1;
	var divHighlight = 'div_highlight'+ intTextBox;
	var contentID = document.getElementById("highlight-col");
	var newTBDiv = document.createElement("div");
	newTBDiv.setAttribute("id","strTextHl"+intTextBox);
	newTBDiv.innerHTML = "<br /><input type='text' id='" + intTextBox + "' name='highlights[]'><a href='javascript:void(0);' onclick='removeHighlight("+intTextBox+")'  name='highlightDelete'>&nbsp;&nbsp;[-]</a><br /><div id='" + divHighlight + "' />";
	contentID.appendChild(newTBDiv);
	
};

//function to remove highlights
var removeHighlight = function(intText)
{

	if(intText != 0)
	{
		var contentID = document.getElementById("highlight-col");
		contentID.removeChild(document.getElementById("strTextHl"+intText));
		
	}
};


//function to add screens
var addScreens = function(){
	
	intTextBox = intTextBox + 1;
	var divScreen 			= 'div_Screens'+ intTextBox;
	var div_pax_level_1     = 'div_pax_level_1'+intTextBox;
	var div_pax_level_2     = 'div_pax_level_2'+intTextBox;
	var div_pax_level_3     = 'div_pax_level_3'+intTextBox;
	var contentID = document.getElementById("screen-selection");
	var newTBDiv = document.createElement("div");
	newTBDiv.setAttribute("id","strTextScr"+intTextBox);
	newTBDiv.innerHTML = "<br/><p>Screen"+intTextBox+"</p><p>&nbsp;<label for='paxLevel1'>No of pax Level1:<br /><input name='pax_level_1[]' type='text' value=''><div id='" + div_pax_level_1 + "' ></div></p><p><label for='paxLevel2'>No of pax Level2:<br /><input name='pax_level_2[]' type='text' value=''><div id='" + div_pax_level_2 + "' ></div></p><p><label for='paxLevel3'>No of pax Level3:<br /><input name='pax_level_3[]' type='text' value=''><div id='" + div_pax_level_3 + "' ></div></p>";
	document.getElementById('no_of_screen').value =  intTextBox;
	contentID.appendChild(newTBDiv);
	
};
var addMoreScreens = function(){
	var noofScreen = document.getElementById("no_of_screen").value;
	alert(noofScreen);
	noofScreen = parseInt(noofScreen) +parseInt(1);
	var divScreen 			= 'div_Screens'+ noofScreen;
	var div_pax_level_1     = 'div_pax_level_1'+noofScreen;
	var div_pax_level_2     = 'div_pax_level_2'+noofScreen;
	var div_pax_level_3     = 'div_pax_level_3'+noofScreen;
	var contentID = document.getElementById("screen-selection");
	var newTBDiv = document.createElement("div");
	newTBDiv.setAttribute("id","strTextScr"+noofScreen);
	newTBDiv.innerHTML = "<br/><p>Screen"+noofScreen+"<input type='hidden' name='no_of_screen' id='no_of_screen' value='"+noofScreen+"'></p><p>&nbsp;<label for='paxLevel1'>No of pax Level1:<br /><input name='pax_level_1[]' type='text' value=''><div id='" + div_pax_level_1 + "' ></div></p><p><label for='paxLevel2'>No of pax Level2:<br /><input name='pax_level_2[]' type='text' value=''><div id='" + div_pax_level_2 + "' ></div></p><p><label for='paxLevel3'>No of pax Level3:<br /><input name='pax_level_3[]' type='text' value=''><div id='" + div_pax_level_3 + "' ></div></p>";
	document.getElementById('no_of_screen').value =  noofScreen;
	contentID.appendChild(newTBDiv);
	
};
/*
//function to display screens
function addScreens(tableID)
{
	//Clearing the td
	$('#screen-selection').html('');
	
	var no_of_screen = document.getElementById('no_of_screen').value;
	
	//checking whether no of screen is empty or not
	document.getElementById('div_no_of_screen').innerHTML = "";
	if(no_of_screen == "")
	{
		document.getElementById('div_no_of_screen').innerHTML = "<span class='error'>Please Enter No of Screen</span>";
	}
	
	
	var body = document.getElementById('screen-selection');
	
	  
	     // creates a table element and a tbody element
	        var tbl     = document.createElement("table");
	        var tblBody = document.createElement("tbody");

	        //Creating all cells
	        for (var j = 0; j < no_of_screen; j++) 
	        {
	           //Creates a table row
	            var row = document.createElement("tr");

	           
                var cell = document.createElement("td");
                var cellText = document.createTextNode("Screen"+(j+1)+":");	                
                cell.appendChild(cellText);	              
                row.appendChild(cell);
            
	           
	            for (var i = 0; i < 3; i++)
	            {
					                //Create a td element and a text node, make the text
	            				    //node the contents of the td, and put the td at the end of the table row
	            	
					                var cell = document.createElement("td");
					                var cellText   = document.createTextNode("No of pax Level"+(i+1)+":");
					                var inputText  = document.createElement('input');		
					                inputText.type = "text";
					                inputText.name =  "pax_level_"+(i+1)+"[]";
					                var div        =  document.createElement('div');
					                div.setAttribute("id","div_pax_level_"+(i+1)+(j));
					                
					                cell.appendChild(cellText);
					                cell.appendChild(inputText);
					                cell.appendChild(div);
					                row.appendChild(cell);
	            }
	            
	            
	            //add the row to the end of the table body
	            tblBody.appendChild(row);
	        }

	       //put the tbody in the table
	        tbl.appendChild(tblBody);
	        
	        //appends table into body
	        body.appendChild(tbl);
	        
	   
	
}*/

//validating restaunt overview form
function validateOverview()
{
	//calling function for clearing divs 
		divOverview();
		
	//retrieving the form elements
	var overview       = document.getElementById('details').value;
	var highlights 	   = document.getElementsByName('highlights[]');
	var no_of_tables   = document.getElementById('no_of_tables').value;
	var no_of_pax      = document.getElementById('no_of_pax').value;
	var paxLevel1 	   = document.getElementsByName('pax_level_1[]');
	var paxLevel2 	   = document.getElementsByName('pax_level_2[]');
	var paxLevel3 	   = document.getElementsByName('pax_level_3[]');
	var counter = 0;
		
	//check for overview
	if(overview == "")
	{
		document.getElementById('div_overview').innerHTML = "<span class='error'>Please Enter Overview</span>";
		counter=counter+1;
	}
	//Check for Highlights
	for (var i=0; i < highlights.length; i++)
	{
		if(highlights[i].value == "")
		{
			
				if(i==0)
				{
					document.getElementById('div_highlight').innerHTML = "<span class='error'>Please Enter Highlights</span>";
					counter=counter+1;
				}
				else
				{
					document.getElementById('div_highlight'+i).innerHTML = "<span class='error'>Please Enter  Highlights</span>";
					counter=counter+1;
				}
		}
	}
	//check for number of tables
	if(no_of_tables == "")
	{
		document.getElementById('div_no_table').innerHTML = "<span class='error'>Please Enter No of Table</span>";
		counter=counter+1;
	}
	else
	{
		if (!IsNumeric(no_of_tables))
		{
			
				document.getElementById('div_no_table').innerHTML = "<span class='error'>Please Enter Number Only</span>";
				counter=counter+1;
			
		}
	}
	//check for number of tables
	if(no_of_pax == "")
	{
		document.getElementById('div_no_pax').innerHTML = "<span class='error'>Please Enter No of Pax</span>";
		counter=counter+1;
	}
	else
	{
		if (!IsNumeric(no_of_pax))
		{
			
				document.getElementById('div_no_pax').innerHTML = "<span class='error'>Please Enter Number Only</span>";
				counter=counter+1;
			
		}
	}
	if(document.getElementById('screen-selection').innerHTML == "")
	{
		document.getElementById('div_no_of_screen').innerHTML = "<span class='error'>Please Click on Create Pax</span>";
		counter=counter+1;
	}
	

	//Check for Pax Level 1
	var firstLevelValue =0;
	for (var i=0; i < paxLevel1.length; i++)
	{
		
		firstLevelValue =  parseInt(firstLevelValue) + parseInt(paxLevel1[i].value);
		if (!IsNumeric(paxLevel1[i].value))
		{
				
				  document.getElementById('div_pax_level_1'+(i+1)).innerHTML = "<span class='error'>Please Enter Number Only</span>";
				  counter=counter+1;
				
		}
		else
		{
				document.getElementById('div_pax_level_1'+(i+1)).innerHTML = "";
		}
		
	}
	
	//Check for Pax Level 2
	var SecLevelValue =0;
	for (var j=0; j < paxLevel2.length; j++)
	{
		SecLevelValue =  parseInt(SecLevelValue) + parseInt(paxLevel2[j].value);
		
		if (!IsNumeric(paxLevel2[j].value))
		{
			  document.getElementById('div_pax_level_2'+(j+1)).innerHTML = "<span class='error'>Please Enter Number Only</span>";
			  counter=counter+1;
			
		}
		else
		{
			document.getElementById('div_pax_level_2'+(j+1)).innerHTML = "";
		}
		
	}
	
	//Check for Pax Level 3
	var ThrLevelValue =0;
	for (var k=0; k < paxLevel3.length; k++)
	{
		ThrLevelValue =  parseInt(ThrLevelValue) + parseInt(paxLevel3[k].value);
		if (!IsNumeric(paxLevel3[k].value))
		{
				
				document.getElementById('div_pax_level_3'+(k+1)).innerHTML = "<span class='error'>Please Enter Number Only</span>";
				  counter=counter+1;
				
		}
		else
		{
				document.getElementById('div_pax_level_3'+(k+1)).innerHTML = "";
		}
				
		
	}
	
	//checking whether number of pax is greater than the toalt no of pax given	
	var total = 0;
	total = parseInt(firstLevelValue) + parseInt(SecLevelValue) +parseInt(ThrLevelValue);
	
		if(no_of_pax < total)
		{
			document.getElementById('divTotalPax').innerHTML = "<span class='error'>Screen pax level values should not be greater than max pax value</span>";
			counter = counter + 1;
		}
	
	if(counter > 0)
	{
		return false;
	}
	else
	{
		return true;
	}
	
	
		
}
//function to clear divs of restaurant overview
function divOverview()
{
	document.getElementById('div_overview').innerHTML     =  "";
	document.getElementById('div_highlight').innerHTML    =  "";
	document.getElementById('div_no_table').innerHTML     =  "";
	document.getElementById('div_no_pax').innerHTML     =  "";
	document.getElementById('div_no_of_screen').innerHTML =  "";
	document.getElementById('divTotalPax').innerHTML = "";
}
//This function is used to check the string is Numeric
function IsNumeric(sText) {
    var ValidChars = "0123456789";
    var IsNumber = true;
    var Char;


    for (i = 0; i < sText.length && IsNumber == true; i++) {
        Char = sText.charAt(i);
        if (ValidChars.indexOf(Char) == -1) {
            IsNumber = false;
        }
    }
    return IsNumber;

}

//function to validate video
function validateVideo()
{
	//clearing divs
	document.getElementById('div_name').innerHTML        =  "";
	document.getElementById('div_document').innerHTML    =  "";
	
	//retrieving fields
	var name         = document.getElementById('name').value;
	var file        = document.getElementById('document').value;
	var counter      = 0;
	
	//check for name
	if(name == "")
	{

		document.getElementById('div_name').innerHTML = "<span class='error'>Please Enter Video Name</span>";
		counter=counter+1;
	
	}
	//check for document
	if(file == "")
	{
		document.getElementById('div_document').innerHTML = "<span class='error'>Please Upload Video</span>";
		counter=counter+1;
	}

	if(counter > 0)
	{
		return false;
	}
	else
	{
		return true;
	}
}
//function to validate image
function validateImages()
{
	//clearing divs
	document.getElementById('div_name').innerHTML        =  "";
	document.getElementById('div_document').innerHTML    =  "";
	
	//retrieving fields
	var name         = document.getElementById('name').value;
	var file        = document.getElementById('document').value;
	var counter      = 0;
	
	//check for name
	if(name == "")
	{

		document.getElementById('div_name').innerHTML = "<span class='error'>Please Enter Image Name</span>";
		counter=counter+1;
	
	}
	//check for document
	if(file == "")
	{
		document.getElementById('div_document').innerHTML = "<span class='error'>Please Upload Image</span>";
		counter=counter+1;
	}

	if(counter > 0)
	{
		return false;
	}
	else
	{
		return true;
	}
}